
#ifndef FOOD_H
#define FOOD_H

#include "AnimatedEntity.h"
#include "defs.h"
#include "Baby.h"
#include "ParticleSystem.h"

enum eFoodState { Food_PreEntering, Food_Entering, Food_Waiting, Food_Launched, Food_Exiting, Food_End, Food_Disappearing };

class Food : public AnimatedEntity
{
private:
	float m_fTimeEnterState;
    
    eFoodState m_eFoodState;

	Vector2 m_vPosInit, m_vPosEnd;
    Vector2 m_vScaleInit, m_vScaleEnd;
	
    eBabyPos m_eBabyPos;
    
    // entering state
    float m_fPreenteringTimer;
    float m_fEnteringTimer;
    float m_fWaitingTimer;
    // to modify the path of the food once launched, save the direction and the speed
    Vector2 m_vDirection;
    float m_fSpeed;
    float m_fLaunchedTimer;
    // end state
    float m_fExitingTimer;
	
    bool m_bFoodSpawned;
    bool m_bFirstLaunchedUpdate;
    
    // if its food used in the multifood minigame, and its position (1 left, 2 middle, 3 right)
    bool m_bMultiFood;
    int m_iMultiPosition;
    
public:
   	Food(std::string _sFood);
    ~Food();
    
	eFoodState getState() { return m_eFoodState; }

	void setState(eFoodState _iState);
    bool getMultiFood() { return m_bMultiFood; }
    void setMultiFood(bool _bValue, int _iPos) { m_bMultiFood = _bValue; m_iMultiPosition = _iPos; }
    float getTimeInWaitingState()
    {
        if (m_eFoodState == Food_Waiting)
        {
            return m_fWaitingTimer;
        }
        else
        {
            return -1.0f;
        }
    }
    
    void launch(eBabyPos _iBabyPos);
    
    void update();
    
    void checkLaunched();
    void updateTrail();
    bool getSpawnedFood() { return m_bFoodSpawned; }
    void setSpawnedFood(bool _bValue) { m_bFoodSpawned = _bValue; }
    bool getFirstLaunchedUpdate() { return m_bFirstLaunchedUpdate; }
    Vector2 getBabyPosition(eBabyPos ePos);
    
    void disappear();
};

#endif
